import instance from './index.js'
import {
	encrypt,
	decrypt
} from '@/utils/crypto'

function encryptFun(data) {
	return {
		parameter: encrypt(data)
	}
}

export const articlePolicy = (body) => {
	return instance({
		url: '/api/v1/article/policy',
		method: 'GET',
		params: {
			...encryptFun(body)
		}
	})
}

// 退出登录
export const userLogout = (body) => {
	return instance({
		url: '/api/user/logout',
		method: 'POST',
		data: {
			...encryptFun(body)
		}
	})
}

// 关于我们|协议
export const commonGywm = (body) => {
	return instance({
		url: '/api/common/gywm',
		method: 'POST',
		data: {
			...encryptFun(body)
		}
	})
}

// 修改个人信息
export const userProfile = (body) => {
	return instance({
		url: '/api/user/profile',
		method: 'POST',
		data: {
			...encryptFun(body)
		}
	})
}

// 上传文件
export const commonUpload = (body) => {
	return instance({
		url: '/api/common/upload',
		method: 'POST',
		data: body,
		headers: {
			'Content-Type': 'multipart/form-data'
		},
	})
}

// 上传文件 oss 配置接口
export const commonOssConfig = (body) => {
	return instance({
		url: '/api/common/ossConfig',
		method: 'GET',
		params: {
			...encryptFun(body)
		},
	})
}

// 上传文件  oss
export const commonUploadOSS = (url, body) => {
	return instance({
		url: url,
		baseURL: '',
		method: 'POST',
		data: body,
		headers: {
			// 'Content-Type': 'multipart/form-data'
		},
	})
}

// 地址栏列表
export const userAddresslist = (body) => {
	return instance({
		url: '/api/user/addresslist',
		method: 'POST',
		method: 'GET',
		params: {
			...encryptFun(body)
		}
	})
}


// 添加地址
export const userAddAddress = (body) => {
	return instance({
		url: '/api/user/add_address',
		method: 'POST',
		data: {
			...encryptFun(body)
		}
	})
}

// 币种列表
export const indexCurrency = (body) => {
	return instance({
		url: '/api/index/currency',
		method: 'GET',
		params: {
			...encryptFun(body)
		}
	})
}

// 网络列表
export const indexNetwork = (body) => {
	return instance({
		url: '/api/index/network',
		method: 'GET',
		params: {
			...encryptFun(body)
		}
	})
}

// 删除地址
export const userDelAddress = (body) => {
	return instance({
		url: '/api/user/del_address',
		method: 'GET',
		params: {
			...encryptFun(body)
		}
	})
}

// 计量单位
export const commonCurrencylist = (body) => {
	return instance({
		url: '/api/common/currencylist',
		method: 'GET',
		params: {
			...encryptFun(body)
		}
	})
}

// 校验手机号
export const smsCheck = (body) => {
	return instance({
		url: '/api/sms/check',
		method: 'POST',
		data: {
			...encryptFun(body)
		}
	})
}

// 校验邮箱
export const emsCheck = (body) => {
	return instance({
		url: '/api/ems/check',
		method: 'POST',
		data: {
			...encryptFun(body)
		}
	})
}

// 修改手机号
export const userChangemobile = (body) => {
	return instance({
		url: '/api/user/changemobile',
		method: 'POST',
		data: {
			...encryptFun(body)
		}
	})
}

// 修改/绑定邮箱
export const userChangeemail = (body) => {
	return instance({
		url: '/api/user/changeemail',
		method: 'POST',
		data: {
			...encryptFun(body)
		}
	})
}


// 绑定手机号
export const userBindmobile = (body) => {
	return instance({
		url: '/api/user/bindmobile',
		method: 'POST',
		data: {
			...encryptFun(body)
		}
	})
}


// 修改密码
export const userEditpwd = (body) => {
	return instance({
		url: '/api/user/editpwd',
		method: 'POST',
		data: {
			...encryptFun(body)
		}
	})
}


// 修改交易密码
export const userSetSecpassword = (body) => {
	return instance({
		url: '/api/user/set_secpassword',
		method: 'POST',
		data: {
			...encryptFun(body)
		}
	})
}